webpackJsonp([21],{

/***/ 0:
/***/ function(module, exports, __webpack_require__) {

	var url = __webpack_require__(10);
	var template = __webpack_require__(11);
	var main = __webpack_require__(13);
	var form = __webpack_require__(20);
	var module = __webpack_require__(21);

	//模板配置
	var tplArr = [];
	var cartTpl = __webpack_require__(38);
	tplArr['cart'] = template.compile(cartTpl.replace(/^\s*|\s*$/g, ""));

	function Index() {
	    _this = this;
	    this.main = function () {
	        main.event(this, 'tap', 'i-click');
	        main.event(this, 'change', 'i-change');
	        this.init();
	    };

	    this.getContent = function (getUrl, changeUrl, deleteUrl) {
	        main.post(getUrl, {}, function (ret) {
	            if (ret.code != 1) {
	                $(".content").html("购物车为空!");
	                return false;
	            };
	            var dataPrice = {
	                tType: "price",
	                price: "0",
	                reduce: "0.00",
	                checkSingle: true
	            };
	            var dataOrder = {
	                tType: "orderList",
	                dataList: []
	            };
	            for (var n in ret.data) {
	                var _json = ret.data[n];
	                var _data = {
	                    "cart_id": _json.cart_id,
	                    "id": _json.good_id,
	                    "title": _json.good_name,
	                    "attr": [],
	                    "num": _json.good_sku,
	                    "spec": _json.colour + "," + _json.cup + "," + _json.size,
	                    "price": _json.shop_price,
	                    "image": _json.small_image,
	                    "n": _json.good_number
	                };
	                dataOrder.dataList.push(_data);
	            }
	            var data = {
	                tType: "content",
	                price: tplArr['cart'](dataPrice),
	                orderList: tplArr['cart'](_this.getOrderList(dataOrder)),
	                link: '', //_this.jumpUrl,
	                num: "0"
	            };
	            $(".content").html(tplArr['cart'](data));
	        });
	    };

	    this.getOrderList = function (data) {
	        var ret = data;
	        $.each(ret.dataList, function (i, v) {
	            var r = [];
	            r.push(v);
	            v.content = module.ordersGoodsInfo(r);
	        });
	        return ret;
	    };

	    //更换购物车数量
	    this.changeCount = function (ths, type) {
	        if (!!_this.addAjax) {
	            console.info("频次太快");
	            return false;
	        }
	        if (type != 1 && ths.siblings("input").val() == "1") {
	            return false;
	        }
	        _this.addAjax = true;
	        var num = parseInt(ths.siblings("input").val());
	        if (type == 1) {
	            ths.siblings("input").val(++num);
	        } else if (num > 1) {
	            ths.siblings("input").val(--num);
	        }
	        _this.choosePro();
	        var _id = ths.attr("cart");
	        main.post(_this.changeUrl, { id: _id, num: num }, function (ret) {
	            if (ret.code == 1) {
	                _this.addAjax = false;
	            }
	        });
	    };

	    //选中商品,修改价格,修改链接
	    this.choosePro = function (ths, id) {
	        var _input = $(".mw>input"),
	            num = 0,
	            price = 0,
	            ids = '';
	        $.each(_input, function (i, v) {
	            if (!!$(this).prop("checked")) {
	                num++;
	                var dv = $(this).parent(".mw").siblings(".orders-goods-info");
	                var p = dv.find(".proprice").html(),
	                    n = dv.find(".pronum").val();
	                // console.info(p, n)
	                price += parseFloat(p) * parseFloat(n);
	                ids += $(this).attr("cart") + ",";
	            } else {
	                $("#all").prop("checked", false);
	            }
	        });
	        $(".pronumber").html(num);
	        if (!price) price = 0;
	        $(".propriceall").html(price);
	        if (!ids) {
	            $(".gotoConfirm").attr("href", "");
	        } else {
	            $(".gotoConfirm").attr("href", _this.jumpUrl + "?id=" + ids);
	        }
	    };
	    //全选
	    this.chooseAll = function (ths) {
	        if (!!ths.prop("checked")) {
	            $(".mw>input").prop("checked", true);
	        } else {
	            $(".mw>input").prop("checked", false);
	        }
	        _this.choosePro();
	    };

	    //删除购物车
	    this.deleteCart = function (ths, id) {
	        main.post(_this.deleteUrl, { id: id, id: id }, function (ret) {
	            if (ret.code == 1) {
	                $(ths).parents("li.orders-goods-info").remove();
	                _this.choosePro();
	            }
	        });
	    };

	    this.init = function () {
	        this.getUrl = url.postCartList;
	        this.changeUrl = url.postUpdateCartNum;
	        this.deleteUrl = url.postDestroyCart;
	        this.jumpUrl = "order-confirm";
	        this.getContent(this.getUrl, this.changeUrl, this.deleteUrl);
	        this.addAjax = false;
	    };
	    return this.main();
	};

	var index = new Index();

/***/ },

/***/ 20:
/***/ function(module, exports, __webpack_require__) {

	var url = __webpack_require__(10);
	var template = __webpack_require__(12);
	var main = __webpack_require__(13);
	var modalTpl = __webpack_require__(18);

	//模板配置
	var tplArr = [];
	template.config('escape', false);
	tplArr['modal'] = template.compile(modalTpl.replace(/^\s*|\s*$/g, ""));

	//获取验证码
	function getCode(_dom, url, id) {
	  var _mobile = $('input[name="mobile"]').val();
	  var code = $('input[name="code"]').val();
	  if (_dom.text() != '获取验证码') {
	    return false;
	  }
	  if (_mobile == "") {
	    jsAlert('请输入手机号码');
	  } else if (/^1[3|4|5|7|8]\d{9}$/.test(_mobile) == false) {
	    jsAlert('手机号码格式有误');
	  } else {
	    _dom.text("校验中");
	    $.post(url, { "user_id": id, "mobile": _mobile }, function (json, textStatus) {
	      _json = json;
	      if (_json.code == 1) {
	        var tm = 60;
	        var tmr = setInterval(function () {
	          tm--;
	          if (tm > 0) {
	            _dom.text(tm + "秒");
	          } else {
	            _dom.text('获取验证码');
	            clearInterval(tmr);
	            tm = 60;
	            //_dom.attr('onclick','join.getCode()')
	          }
	        }, 1000);

	        jsAlert('验证码已发送');
	      } else if (_json.code == 2) {
	        jsAlert(_json.data);
	        _dom.text('获取验证码');
	      } else if (_json.code == 200) {
	        jsAlert(_json.data);
	        _dom.text('获取验证码');
	      }
	    }, 'json');
	  }
	}
	//弹窗
	function jsAlert(text, Fun) {
	  if (!Fun) {
	    Fun = 'm-click="modalAlertClose"';
	  }
	  var data = {
	    "type": "1",
	    "ico": 'warn',
	    "text": text,
	    "Callback": Fun
	  };
	  $('body').append(tplArr['modal'](data));
	}
	//表单数据整理
	// function ajaxSubmit_o(obj,module,but) {

	//   //var url = $(obj).attr("action") || window.location.href;
	//   var callback_name = $(obj).attr("callback");
	//   var url = $(obj).attr("action");
	//   var data = {};
	//   var ipts = {};
	//   $('input[name],textarea[name],select[name]',obj).each(function(item){
	//       var name = $(this).attr('name');
	//       var value = $(this).val();
	//       var ipt = $(this).attr('ipt');
	//       var isArray = /\[\]$/;
	//       if(isArray.test(name)){
	//           if(!data[name]){data[name]=[]}
	//           if(!ipts[name]){ipts[name]=[]}
	//           data[name].push(value);
	//           ipts[name].push(value,ipt);
	//       }else{
	//           data[name] = value;
	//           ipts[name] = [value,ipt];
	//       }
	//   });

	//   if(!yzForm(ipts)){return false;}
	//   but.attr('isSubmit','false').text('提交中...');
	//   $.ajax({
	//       url: url,
	//       type: "get",
	//       data: data,
	//       dataType: "json",
	//       success: function(ret){
	//           //if(ret.sms_success == "1"){
	//               //if(isNotEmpty(callback)) {
	//                 //_this.id = ret.success_id;
	//                 //jsConfirm('提示','请您确认所有填写的信息准确无误！',callback_name);
	//                 module[callback_name](ret);
	//               //}
	//           //}else if(ret.sms_success == "0"){
	//               //jsAlert("验证码错误");
	//           //}
	//       },
	//       error:function(ret){

	//       }
	//   });
	// }
	//表单数据整理
	function ajaxSubmit(obj, module, but) {
	  //console.info(module)
	  var but_val = but.html();
	  if (but_val == "提交中...") {
	    console.info("频次太快");
	    return false;
	  }
	  //var url = $(obj).attr("action") || window.location.href;
	  var callback_name = $(obj).attr("callback");
	  var url = $(obj).attr("action");
	  var formtype = $(obj).attr("f-type");
	  var data = {};
	  var ipts = {};
	  $('input[name],textarea[name],select[name]', obj).each(function (item) {
	    var name = $(this).attr('name');
	    var value = $(this).val();
	    var ipt = $(this).attr('ipt');
	    var isArray = /\[\]$/;
	    if (isArray.test(name)) {
	      if (!data[name]) {
	        data[name] = [];
	      }
	      if (!ipts[name]) {
	        ipts[name] = [];
	      }
	      data[name].push(value);
	      ipts[name].push(value, ipt);
	    } else {
	      data[name] = value;
	      ipts[name] = [value, ipt];
	    }
	  });

	  if ($("input[name='is_default']:checked").length == 1) {
	    data.is_default = 1;
	  } else {
	    data.is_default = 0;
	  }

	  if (!yzForm(ipts)) {
	    return false;
	  }
	  but.attr('isSubmit', 'false').html('提交中...');

	  //console.info(data)
	  data.openid = openid;
	  // $("body").html(data.serverId);
	  $.ajax({
	    url: url, //+"?openid_test=ojtKJjq93sF3dOoz4lA12MrxtcUk",
	    type: "post",
	    data: data,
	    dataType: "json",
	    success: function (ret) {
	      // console.info(ret)
	      //if(ret.sms_success == "1"){
	      //if(isNotEmpty(callback)) {
	      //_this.id = ret.success_id;
	      //jsConfirm('提示','请您确认所有填写的信息准确无误！',callback_name);
	      module[callback_name](ret);
	      but.html(but_val);
	      //}
	      //}else if(ret.sms_success == "0"){
	      //jsAlert("验证码错误");
	      //}
	    },
	    error: function (ret) {
	      but.html(but_val);
	      console.info(ret);
	    }
	  });
	}
	//方法验证
	function yzForm(data) {
	  var Ctrue = true;
	  var hour = $('select[name="sendplan_hour"]').val();
	  for (ipt in data) {
	    if (data[ipt][1] == 'true') {
	      continue;
	    }
	    switch (ipt) {

	      case 'name':
	        if (data[ipt][0] == "") {
	          isCtrue('请输入名字');return false;
	        }
	        break;

	      case 'mobile':
	        if (data[ipt][0] == "") {
	          isCtrue('请输入手机号码');return false;
	        } else if (/^1[3|4|5|7|8]\d{9}$/.test(data[ipt][0]) == false) {
	          isCtrue('手机号码格式有误');return false;
	        }
	        break;

	      case 'address':
	        if (data[ipt][0] == "") {
	          isCtrue('请输入详细地址');return false;
	        }
	        break;
	      case 'shipping_id':
	        if (data[ipt][0] == "") {
	          isCtrue('请选择物流');return false;
	        }
	        break;
	      case 'shipping_number':
	        if (data[ipt][0] == "") {
	          isCtrue('请填写物流单号');return false;
	        }
	        break;

	      // case 'is_default':
	      //    if(data[ipt][0]==""){isCtrue('请选择');return false;}
	      // break;
	    }
	  }
	  function isCtrue(text) {
	    Ctrue = false;
	    main.alert({
	      "title": "提示",
	      "content": text
	    });
	  };
	  return Ctrue;
	}

	exports.getCode = getCode;
	exports.jsAlert = jsAlert;
	exports.ajaxSubmit = ajaxSubmit;
	exports.yzForm = yzForm;

/***/ },

/***/ 38:
/***/ function(module, exports) {

	module.exports = "{{if tType== 'content'}}\n\t{{if !!orderList}}\n\t\t{{orderList}}\n\t{{/if}}\n\t{{if !!price}}\n\t\t{{price}}\n\t{{/if}}\t\n\t<div class=\"ui-btn-wrap pad-btn\">  \n     <a href=\"{{link}}\" {{if !!click}}i-click=\"{{click}}\"{{/if}} class=\"gotoConfirm ui-btn-pink ui-btn-lg\">去结算（共<span class=\"pronumber\">{{num}}</span>件）</a>\n    </div> \n{{/if}}\n{{if tType== 'orderList'}} \n\t\t\t<ul class=\"ui-list ui-border-tb cart-order\">\n\t\t    {{each dataList as v i}}\n\t\t\t    <li class=\"ui-border-t orders-goods-info ui-whitespace\">\n\t\t\t    \t<div class=\"ui-list-info mw ui-checkbox-s\">\n\t\t\t    \t\t<input id=\"{{v.id}}\" cart=\"{{v.cart_id}}\" i-change=\"choosePro, {{v.id}}\" type=\"checkbox\">\n\t\t\t    \t</div>\n\t\t\t        <div class=\"ui-list-info orders-goods-info\">\n\t\t\t            {{v.content}}\n\t\t\t            <div class=\"num\">\t\t\t\t\t\t\t\n\t\t\t            \t<a i-click=\"changeCount,0\" cart=\"{{v.cart_id}}\" class=\"ui-btn _btn\">-</a>\n\t\t\t\t\t\t\t<input type=\"text\" class=\"pronum\" readonly=\"readonly\" value=\"{{v.n}}\">\n\t\t\t            \t<a i-click=\"changeCount,1\" cart=\"{{v.cart_id}}\" class=\"ui-btn _btn\">+</a>\n\t\t\t            </div>\n\t\t\t            <a i-click=\"deleteCart,{{v.cart_id}}\" class=\"ui-btn _btn\">删除</a>\n\t\t\t        </div>\t\t\t         \n\t\t\t    </li>\n\t\t\t    {{/each}}\n\t\t\t</ul> \n{{/if}}\n{{if tType== 'price'}}\t\n\t<div class=\"price\">\n\t{{if !!checkSingle}}\n    \t<div class=\"checkSingle pad-tb15 bor-bom ui-whitespace\" ><label for=\"all\" class=\"ui-checkbox-s\"><input id=\"all\" type=\"checkbox\" i-change=\"chooseAll\"> 全选</label></div>\n\t{{/if}}\n\t{{if !!price}}\n\t\t<h3 class=\"center ui-whitespace pad-t10\">总价：<span class=\"fz-18\">￥<t class=\"propriceall\">{{price}}</t></span></h3>\n\t{{/if}}\n\t{{if !!reduce}}\n\t\t<p class=\"center ui-whitespace ui-txt-info fz-13\">(不含运费，已优惠￥{{reduce}})</p>\n\t{{/if}}\n\t</div>\n{{/if}}"

/***/ }

});